/**
 * Created by Joe on 2017/7/27 0027.
 */

/**
 * 各种消息提示框
 *
 * @param target
 * @param type
 * @param message
 */
function alerts(target, type, message) {
    var content = '';
    if (type == 0) {
        content = alert_success(message);
    }
    else if (type == 1) {
        content = alert_info(message);
    }
    else if (type == 2) {
        content = alert_warning(message);
    }
    else if (type == 3) {
        content = alert_danger(message);
    }
    $("#" + target).find("div.alerts").remove();
    $(content).appendTo("#" + target);
}

function clearAlerts(target) {
    $("#" + target).find("div.alerts").remove();
}
/**
 *
 *
 * '  <div class="form-group">' +
 '   <div class="col-sm-6 col-sm-offset-2"><div class="alert alert-success">' +
 '<button aria-hidden="true" data-dismiss="alert" class="close" type="button">× </button>'+content+'. <a class="alert-link" href="#">Alert Link</a>.' +
 '</div> </div> </div>'
 *
 *
 * @param content
 * @returns {string}
 */
function alert_success(message) {
    return '<div class="form-group alerts"><div class="col-sm-6 col-sm-offset-2"><div class="alert alert-success">' + message + '.</div> </div> </div>';
}

function alert_info(message) {
    return '<div class="form-group alerts"><div class="col-sm-6 col-sm-offset-2"><div class="alert alert-info">' + message + '.</div> </div> </div>';
}

function alert_warning(message) {
    return '<div class="form-group alerts"><div class="col-sm-6 col-sm-offset-2"><div class="alert alert-warning">' + message + '.</div> </div> </div>';
}

function alert_danger(message) {
    return '<div class="form-group alerts"><div class="col-sm-6 col-sm-offset-2"><div class="alert alert-danger">' + message + '.</div> </div> </div>';
}